set scheme s1color

use repeated_cross_section, clear

// muslim indicator
gen muslim=(paiperc=="06"|paiperc=="08")

// interactions
gen inter=muslim*treatedcoh

// cluster variable
egen pbpl=group(paiperc)

// group cohorts
gen cohort=1980 if birthyear==1980|birthyear==1981
replace cohort=1982 if birthyear==1982|birthyear==1983
replace cohort=1984 if birthyear==1984|birthyear==1985
replace cohort=1986 if birthyear==1986|birthyear==1987
replace cohort=1988 if birthyear==1988|birthyear==1989
replace cohort=1990 if birthyear==1990|birthyear==1991
replace cohort=1992 if birthyear>=1992

// cohortXmuslim interactions
tab cohort, gen(c_)
forval x=1/7 {
	gen interc_`x'=c_`x'*muslim
}

drop atschool_prebac
gen atschool_prebac=(acteu6==5&forniv>=2&forniv<=6&surveyr<2008)
replace atschool_prebac=(acteu6==5&forniv>=2&forniv<6&surveyr>=2008)
replace atschool_prebac=0 if forniv==.


local sample if pnai28=="10" & female==1   
local cl pbpl
estimates clear
reg atschool_prebac interc_2 interc_3 interc_4 interc_5 interc_6 interc_7 i.pbpl i.birthyear i.surveyr i.ag##i.muslim `sample', cluster(`cl')   
eststo c1
coefplot (c1, ciopts(lcolor(cranberry) recast(rcap)) mcolor(cranberry)), ///
omitted keep(interc_*) ci(90) vertical yline(0, lcolor(gs5)) xline(3, lcolor(gs10)) ///
coeflabels(interc_1="1980" interc_2="1982" interc_3="1984" interc_4="1986" interc_5="1988" interc_6="1990" interc_7="1992") ///
ytitle("Differential treatment effect") xtitle("Year of birth") title("Dep. variable: Enrolled in secondary")



